//draw a rect with texture.
//require Primitive is TriangleStrip 
//do not need to set vertex buffer

#version 460
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable


layout (push_constant) uniform SImageWidgetVertexPushConstant
{

   vec2 LeftTopUV;
   // RightBottomUV generally it is (1,1), if not (1,1), it is tile image。
   vec2 RightBottomUV;  
   vec4 TintColor;

   float ZOrder;


} PushConstants;

layout (location = 0) out vec2 outUV;
layout (location = 1) out vec4 outTintColor;

void main() 
{
   /*
      V0                   V1
      ---------------------
      |                   |
      |                   |
      |                   |
      |                   |
      |                   |
      ---------------------
      V2                   V3
   */

   vec2 Position[4];

   Position[0]=vec2(-1,-1);
   Position[1]=vec2(1,-1);
   Position[2]=vec2(-1,1);
   Position[3]=vec2(1,1);

   gl_Position =vec4(Position[gl_VertexIndex],PushConstants.ZOrder ,1);

   vec2 InUV[4];
   InUV[0] = vec2(PushConstants.LeftTopUV.x,PushConstants.LeftTopUV.y);
   InUV[1] = vec2(PushConstants.RightBottomUV.x,PushConstants.LeftTopUV.y);
   InUV[2] = vec2(PushConstants.LeftTopUV.x,PushConstants.RightBottomUV.y);
   InUV[3] = vec2(PushConstants.RightBottomUV.x,PushConstants.RightBottomUV.y);
   
   outUV=InUV[gl_VertexIndex];

   outTintColor=PushConstants.TintColor;
}